﻿<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>中央控制</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link href="<%=path %>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path %>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=path %>/hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=path %>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/style_list.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/public.css" />
<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"><link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
    <style>
        .col-sm-1{
            padding-right: 0;
        }
		JSON
		body {font-size: 14px;padding: 20px;}
		.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
		.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
		.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
		form>div.row{margin-bottom: 16px;}
		a.btn-rounded{margin-right: 16px;}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
		<div class="tabs-container">
			     <ul class=" nav nav-tabs">
			               
			             
			     </ul>
		     <div class="tab-content">		     
					<div class="ibox-content tab-pane active" id="tab-1">
					
					    <div class="row" style="margin-top:10px; " id="show_activity">
					     		<div class="form-group">
						     		<label class="col-sm-1 control-label" style="margin-top:10px;min-width:150px;">业务介绍</label>
						     		<div  id="bs" class="form-group col-sm-3" style="width:500px; height:60px;margin-left:15px; border:1px solid #e0e5ea;">
						     		
                                           
                                    <div class="clear-shadow"></div>
                       
									
									</div><div style="line-height:55px;">	&nbsp;&nbsp;&nbsp;<a id="business"><font color="#1ab394">选择</font></a>	</div>	
						     	</div>
				     	 </div>
					
						
						
						<div class="row">
					     	<div class="form-group">
					     		<label class="col-sm-1 control-label" style="min-width:150px;">员工是否可设置</label>
					     		<div class="col-sm-1" style="margin-top: -10px;" >
					            	<div class="radio radio-primary">
					                <input id="businesstag1" type="radio"  checked="checked" name="code_type" value="0" >
					                <label for="businesstag1" style="min-width:150px;">是</label>
			            			</div>
			            		</div>
			            		<div class="col-sm-1"  style="margin-top: -10px;">
					            	<div class="radio radio-primary">
					                <input id="businesstag2" type="radio" name="code_type" value="1">
					                <label for="businesstag2">否</label>
			            			</div>
			       				 </div>		     	
				     		</div>
				     		
			     		</div>
				     
				     	 <div class="row" style="margin-top:10px;" id="show_linkUrl">
					     		<div class="form-group">
						     		<label class="col-sm-1 control-label" style="margin-top:10px;min-width:150px;">我的推荐</label>
						     		<div id="as" class="form-group col-sm-3" style="width:500px; height:60px;margin-left:15px; border:1px solid #e0e5ea;">
						     		
                                           
                                       <div class="clear-shadow"></div>
                       
									
									</div>	<div style="line-height:55px;">	&nbsp;&nbsp;&nbsp;<a id="activity"><font color="#1ab394">选择</font></a>	</div>			
						     	</div>
				     	 </div>
				     
				     	 <div class="row">
					     	<div class="form-group">
					     		<label class="col-sm-1 control-label" style="min-width:150px;">员工是否可设置</label>
					     		<div class="col-sm-1" style="margin-top: -10px;" >
					            	<div class="radio radio-primary">
					                <input id="activitytag1" type="radio" checked="checked" name="code_type1"value="1" >
					                <label for="activitytag1" style="min-width:150px;">是</label>
			            			</div>
			            		</div>
			            		<div class="col-sm-1"  style="margin-top: -10px;">
					            	<div class="radio radio-primary">
					                <input id="activitytag2" type="radio"name="code_type1" value="2">
					                <label for="activitytag2">否</label>
			            			</div>
			       				 </div>		     	
				     		</div>
				     		
			     		</div>
			     		<div class="row" style="height:20px;">							
						</div>
						<div class="row" style="height:20px;">							
						</div>
			     		 <div class="row">
			     		 
					     	<div class="form-group">
					     		<label class="col-sm-1 control-label" style="min-width:150px;">选择员工</label>
					     		<div class="col-sm-1" style="margin-top: -10px;" >
					            	<div class="radio radio-primary">
					                <input id="department1" type="radio"  checked="checked"name="code_type2" value="all" >
					                <label for="department1" style="min-width:150px;">全部员工</label>
			            			</div>
			            		</div>
			            		<div class="col-sm-1"  style="margin-top: -10px;">
					            	<div class="radio radio-primary">
					                <input id="department2" type="radio" name="code_type2" value="1">
					                <label for="department2">选择部门</label>
			            			</div> 
			            			
			       				 </div>	
			       			<!-- <div class="row">	 
			       			
					 		         <div class="form-group">
		                              <div class="col-sm-3 " style="margin-top: -10px">            
		                    	   
								         <button type="button" class=" btn btn-primary k_verify col-sm-4" id="department">选择</button>
							         </div>
					 	            </div>	     	
				     		    </div> -->
				     		</div>
			     		</div>
			     		<div class="row" style="height:20px;">							
						</div>
			     		 <div class="row">
					     	<div class="form-group">
					     		<label class="col-sm-1 control-label" style="min-width:150px;">新创建通知</label>
					     		<div class="col-sm-1" style="margin-top: -10px;" >
					            	<div class="radio radio-primary">
					                <input id="inform1" type="radio"  checked="checked" name="code_type3" value="no" >
					                <label for="inform1" style="min-width:150px;">不通知</label>
			            			</div>
			            		</div>
			            		<div class="col-sm-1"  style="margin-top: -10px;">
					            	<div class="radio radio-primary">
					                <input  id="inform2" type="radio"name="code_type3"  value="yes">
					                <label for="inform2">通知</label>
			            			</div>
			       				 </div>		     	
				     		</div>
				     		
			     		</div>
				     	<div class="row" style="height:20px;">							
						</div>
			     		 <div id="display" class="row" style="display: none;">
					     	<div class="form-group">
					     		<label class="col-sm-1 control-label" style="min-width:150px;"></label>
					     		<div class="col-sm-1" style="margin-top: -10px;" >
					         
					          <textarea id="context"  rows="5px" cols=""  style="margin-top:10px;min-width:500px;" name="" class="form-control" placeholder=""></textarea>  	
					                <div class="col-sm-1" style="margin-left: 450px;" ><font id="count1" color="green">0</font><font>/56</font></div>
			            		</div>
			            			     	
				     		</div>
				     		
			     		</div>
			     		
			     		 <div class="row" style="margin-right: 700px" >
					 	<div class="col-sm-4"></div>
					 		<div class="form-group">
		                    <div class="col-sm-6 col-sm-offset-1">            
		                    	<button type="button" class=" btn btn-outline btn-primary col-sm-4" id="close" style="margin-right:20px;" organizationImg="">取消</button>   
		                    	&nbsp;&nbsp;&nbsp;&nbsp;     
		                    	<shiro:hasPermission name="activity_authority_list:save">    
								<button type="button" class=" btn btn-primary k_verify col-sm-4" id="commit">提交</button>
								</shiro:hasPermission>
							</div>
					 	</div>
					 </div>
        </div>
				     	 
					
					</div> 
					
					    
					  
			
		</div>
	</div>
	
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="<%=path %>/hplus/js/content.min.js?v=1.0.0"></script>
    <script src="<%=path %>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="<%=path %>/hplus/js/plugins/jsKnob/jquery.knob.js"></script>
    <script src="<%=path %>/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="<%=path %>/hplus/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <script src="<%=path %>/hplus/js/plugins/nouslider/jquery.nouislider.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/switchery/switchery.js"></script>
    <script src="<%=path %>/hplus/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="<%=path %>/hplus/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="<%=path %>/hplus/js/plugins/clockpicker/clockpicker.js"></script>
	<script src="<%=path%>/hplus/js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>
  	<script type="text/javascript">
  	var access_token=$.cookie('access_token');
 	var cid=$.cookie('cid');
 	var uid=$.cookie('uid');
 	var path = "<%=path%>";
  	var storeNames={};
  	var users={};
  	var usersName=[];
  	
  	
  	var cid=$.cookie('cid');
	var  businessIds='';
	var  business_tag='1';
	var  activityIds='';
	var  activity_tag='1'; 
	var  department="all"; 
	var  inform="";
	//0不发短信， 1发短信
	var  isSendSms=0;
	var  blist=[];
	var  alist=[];
	$(function(){
		getProjectUrl();
	})
	
	/* 信息展示方法 */
	function showinfo(){
		var html1="";
		if(blist.length!=0){
			for(var i=0; i<blist.length; i++){
	            var temp = blist[i];
	               html1+='<span id="span2'+i+'"><font id=name'+i+' size="4">'+temp.name+'</font>';
	               html1+='<font id="bid'+i+'"style="display: none;">'+temp.id+'</font>'
	   	           html1+='<img onclick="fb'+i+'();" id="img2'+i+'" width=16px; height=16px; src="'+path+'/images/companycard/delete.png" class="x_lista"  yid="460"></span>&nbsp;&nbsp;&nbsp;';
	        }
	   	    $("#bs").html(html1);
		}
		 
		
	}
	
	
	function showinfo2(){
		var html2="";
		if(alist.length!=0){
			for(var i=0; i<alist.length; i++){
	            var temp = alist[i];
	            html2+='<span id="span'+i+'"><font id=name'+i+' size="4">'+temp.name+'</font>';
                html2+='<font id="aid'+i+'"style="display: none;">'+temp.id+'</font>'
    	        html2+='<img onclick="fa'+i+'();" id="img2'+i+'" width=16px; height=16px; src="'+path+'/images/companycard/delete.png" class="x_lista"  yid="460"></span>&nbsp;&nbsp;&nbsp;';
	        }
	   	    $("#as").html(html2);
		}
		 
		
	}
	//获取项目地址
	function getProjectUrl(){
		inform="您的公司为您生成了一张电子名片,请尽快完成资料,登陆地址:";
		var url=path+"/cardActivityAuthor/ajaxGetUrl";
		$.ajax({
			type:"post",
	  		url:url,
	  		async: false,
	  		success:function(data){
	  			inform+=data.data;
	  		}
		});
		$("#context").attr("placeholder",inform);
	}
	$("#close").click(function(){
		
		location.href=path+"/view/ui/mainView?menuId=100000073&menuName=营销管理&account=15810355456" ;
	})
	/*  判断短信字数 */
	
	  $("#context").keyup(function(){
		  
		  var count =$("#context").val().length;
	
		 // console.log(count);
		  if(count>56){
              var num=$("#context").val().substr(0,56);
              $("#context").val(num);
              func_artdialog("提示","字数不能超过56");
          }else{
        	  $("#count1").html(count); 
          }
		  
	  });
	
	//业务权限
	$("#businesstag1").click(function(){
		
		business_tag="1";
	});
	$("#businesstag2").click(function(){   		
		business_tag="2";
	});
	
	//活动权限
    $("#activitytag1").click(function(){
		
    	activity_tag="1";
	});
	$("#activitytag2").click(function(){   		
		activity_tag="0";
	});
	
	 //短信通知
	 $("#inform1").click(function(){
		 isSendSms=0;
		});
 	$("#inform2").click(function(){ 
 		isSendSms=1;
 	});
	
 	//选择员工
 	
 	 $("#department1").click(function(){
  		
 		department=$("#department1").val();
 	
		});
 	<%-- $("#department2").click(function(){   		
 		$('#bm_men_dian img').attr('src','<%=path%>/images/marketing/s_check.png');
        goumen = 0;
        microPortal();
        bmstore();
		}); --%>
  	/* 显示框删除活动 */
  	function fa0(){
  	
  		$("#span0").remove();
  	}
  	function fa1(){
  
  		$("#span1").remove();
  	}
  	function fa2(){
  
  		$("#span2").remove();
  	}
  	function fa3(){
  	
  		$("#span3").remove();
  	}
  	function fa4(){

  		$("#span4").remove();
  	}
  	
/*     显示框删除业务 */
  	function fb0(){
  	
  		$("#span20").remove();
  	}
  	function fb1(){
  
  		$("#span21").remove();
  	}
  	function fb2(){
  
  		$("#span22").remove();
  	}
  	function fb3(){
  	
  		$("#span23").remove();
  	}
  	function fb4(){

  		$("#span24").remove();
  	}
  	
  	
  	 /* 短信通知控制 */
  	$("#inform2").click(function(){
  		
  		$("#display").css("display","block");
  		
  	});
    $("#inform1").click(function(){
  		
  		$("#display").css("display","none");
  		
  	});
  	/* 业务弹窗控制 */
  	
  	 $("#business").click(function(){
  		businessIds=saveB();
  		func_showActivityDetailDialog3();
  		
  	});
  	/* 推荐弹窗控制 */
   	
  	 $("#activity").click(function(){
  		activityIds=saveA();
  		func_showActivityDetailDialog2();
  		
  	});
  /* 	部门弹窗控制 */
  	 $("#department2").click(function(){
  		department=null;
  		func_showDepartmentDetailDialog();
  		
  	 });
  
     function saveA(){
    	 var activityIds="";
    	 var aid0= $("#aid0").text();
         var aid1= $("#aid1").text();
         var aid2= $("#aid2").text();
         var aid3= $("#aid3").text();
         var aid4= $("#aid4").text();
         if(aid0.length!=0){
         	activityIds+=aid0;
         	activityIds+=",";
         } 
         if(aid1.length!=0){
         	activityIds+=aid1;
         	activityIds+=",";
         }
         if(aid2.length!=0){
         	activityIds+=aid2;
         	activityIds+=",";
         }
         if(aid3.length!=0){
         	activityIds+=aid3;
         	activityIds+=",";
         }
         if(aid4.length!=0){
         	activityIds+=aid4;
         	activityIds+=",";
         }
    	 return activityIds;
     }
     function saveB(){
    	var businessIds="";
    	 var bid0= $("#bid0").text();
         var bid1= $("#bid1").text();
         var bid2= $("#bid2").text();
         var bid3= $("#bid3").text();
         var bid4= $("#bid4").text();
         if(bid0.length!=0){
         	businessIds+=bid0;
         	businessIds+=",";
         } 
         if(bid1.length!=0){
         	businessIds+=bid1;
         	businessIds+=",";
         }
         if(bid2.length!=0){
         	businessIds+=bid2;
         	businessIds+=",";
         }
         if(bid3.length!=0){
         	businessIds+=bid3;
         	businessIds+=",";
         }
         if(bid4.length!=0){
         	businessIds+=bid4;
         	businessIds+=",";
         } 
    	 return businessIds;
     }
  	function save(){
        
  		businessIds=saveB();
  		activityIds=saveA();
        var md_str = '';
		var sms=$("#context").val();	 		
 		if(StringEmpty(sms)){
 			inform=sms;
 		}
       
        
        
        
 		
/*  		console.log(inform);
        console.log("业务id:----------"+businessIds);
        console.log("推荐id:----------"+activityIds);
        console.log("部门名称:---------"+department);
        console.log("businesstag:---------"+business_tag); 
        console.log("activitytag:---------"+activity_tag); 
        console.log("inform:---------"+inform); */
        var jsonParam={};
        jsonParam.access_token=access_token;
        jsonParam.cid=cid;
        jsonParam.uid=uid;
        jsonParam.businessTag=business_tag;
        jsonParam.businessIds=businessIds;
        jsonParam.activityIds=activityIds;
        jsonParam.activityTag=activity_tag;
        jsonParam.departmentIds=department;
        jsonParam.inform=inform;
        jsonParam.isSendSms=isSendSms;
      var url = "<%=path%>/cardActivityAuthor/ajaxCreateCardActivityAuthor"; 
         if(department!=null&&department.length>0 && (businessIds.length>0 || activityIds.length>0)){  	 
        	$.post(url,jsonParam,function(data){
            	 console.log(data);
            	 /*console.log(StringEmpty(data.SMS));
            	console.log(StringEmpty(data.activity)); */
                if(!StringEmpty(data.SMS)&&!StringEmpty(data.activity)){
                	func_artdialog("提示","提交成功");
                	window.location.href=path+"/view/ui/cardHome";
                }else{
                	if(!StringEmpty(data.SMS)){
                		func_artdialog("提示","提交失败！");
                	}else{
                    	func_artdialog("提示","短信发送失败！");	
                	}
                }          	
            });
        }else{        	
        	func_artdialog("提示","您填写的信息不完整");             
        }         
    }
  	$("#commit").click(function(){
  		save();
  	});
  	//自定义弹框
  	function func_artdialog(name,value){
 		var d = dialog({
 			title: name,
 			fixed: true,
 			width: 200,
 	        height:100,
 			content:"<center style='font-size:20px; line-height:100px;'>"+value+"</center>",
 			okValue: "确定",
 			ok: function () {
 				return true;
 			}
 		});
 		d.show();
 	}
  //自定义弹框
  	function func_artdialogComfrim(name,value,func){
 		var d = dialog({
 			title: name,
 			fixed: true,
 			width: 200,
 	        height:100,
 			content:"<center style='font-size:20px; line-height:100px;'>"+value+"</center>",
 			okValue: "确定",
 			ok: function () {
 				func
 				return true;
 			}
 		});
 		d.show();
 	}
  	function func_showActivityDetailDialog2(){
  		activityDetailDialog=dialog({
  			id: "activityDialog",
  	        fixed: true,
  	        width: 1000,
  	        height: 700,
  	        title: '选择活动',
  	        url: path+"/view/ui/authorityShowActivity",
  	        cancel: false,
  	        cancelValue: "关闭"
  		});
  		activityDetailDialog.showModal();
  		$("iframe[name='activityDetailDialog']:visible").attr("scrolling", "auto").css("overflow-x", "hidden").css("overflow-y", "auto");
  	}
  	
  	
  /* 	function func_showActivityDetailDialog3() {
        ActivityDetailDialog = dialog({
            id: "ActivityDetailDialog",
            fixed: true,
            width: 1000,
            height: 700,
            title: '业务列表',
            url: path + "/api/bm/ui/activityDialig",
            cancel: true
        });
        ActivityDetailDialog.showModal();
        $("iframe[name='ActivityDetailDialog']:visible").attr("scrolling", "auto").css("overflow-x", "hidden").css("overflow-y", "auto");
    }) */
  	function func_showActivityDetailDialog3(){
  		activityDetailDialog = dialog({
            id: "activityDetailDialog",
            fixed: true,
            width: 1000,
            height: 700,
            title: '业务列表',
            url: path + "/view/ui/authorityShowBusiness",
            cancel: false,
  	        cancelValue: "关闭"
        });
        activityDetailDialog.showModal();
        $("iframe[name='activityDetailDialog']:visible").attr("scrolling", "auto").css("overflow-x", "hidden").css("overflow-y", "auto");
  	}
  	 
  	
  	function func_showDepartmentDetailDialog(){
  		 activityDetailDialog=dialog({
  			id: "activityDialog1",
  	        fixed: true,
  	        width: 800,
  	        height: 420,
  	        title: '选择部门',
  	        url: path+"/view/ui/showDepartment",
  	        cancel: false,
  	        cancelValue: "关闭"
  		});
  		activityDetailDialog.showModal();
  		$("iframe[name='activityDetailDialog']:visible").attr("scrolling", "auto").css("overflow-x", "hidden").css("overflow-y", "auto");
  	}
    //判断字符串是否为空
  	function StringEmpty(content) {
  		if (content == undefined || content == "" || content == null) {
  			return false;
  		} else {
  			return true;
  		}
  	}
  </script>
</body>
</html>
